package org.gesplan.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author David
 */
@Entity
@Table(name = "work_location")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "WorkLocation.findAll", query = "SELECT w FROM WorkLocation w"),
    @NamedQuery(name = "WorkLocation.findById", query = "SELECT w FROM WorkLocation w WHERE w.id = :id"),
    @NamedQuery(name = "WorkLocation.findByLocationId", query = "SELECT w FROM WorkLocation w WHERE w.locationId = :locationId")
})
public class WorkLocation implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "location_id")
    private String locationId;
    @JoinColumn(name = "work_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Work workId;
    @JoinColumn(name = "location_group_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private LocationGroup locationGroup;


    public WorkLocation() { }


    public WorkLocation(Integer id) {
        this.id = id;
    }


    public Integer getId() {
        return id;
    }


    public void setId(Integer id) {
        this.id = id;
    }


    public String getLocationId() {
        return locationId;
    }


    public void setLocationId(String locationId) {
        this.locationId = locationId;
    }


    public Work getWorkId() {
        return workId;
    }


    public void setWorkId(Work workId) {
        this.workId = workId;
    }


    public LocationGroup getLocationGroup() {
        return locationGroup;
    }


    public void setLocationGroup(LocationGroup locationGroup) {
        this.locationGroup = locationGroup;
    }

    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }


    @Override
    public boolean equals(Object object) {
        if (!(object instanceof WorkLocation)) {
            return false;
        }
        WorkLocation other = (WorkLocation) object;
        return (this.id != null || other.id == null) && (this.id == null || this.id.equals(other.id));
    }


    @Override
    public String toString() {
        return "org.gesplan.entity.WorkLocation[ id=" + id + " ]";
    }
    
    
}